//
// Created by 27411 on 2025/11/8.
//

#ifndef MAIN_C_ORDER_H
#define MAIN_C_ORDER_H

#include "database.h"
#include "student/menu.h"
#include "student/front_user.h"

// 订单项结构体
typedef struct {
    int menu_id;
    int quantity;
    int unit_price;    // 下单时的单价 (整数)
} OrderItem;

// 订单结构体
typedef struct {
    int id;
    int student_id;
    OrderItem items[10];
    int item_count;
    int total_amount;  // 总金额 (整数)
} Order;



void start_order_process();
void settle_and_view_order();//拓展模块：订单总金额结算
void view_history_order();
int create_order(int student_id);
void order_user_query(int order_id);
void ALL_orders(sqlite3_stmt *stmt);
void query_all_orders();

// 函数声明
int db_insert_order(const Order* new_order);
int db_update_student_balance(int student_id, float new_balance);
int db_update_menu_stock(int menu_id, int new_stock);

#endif //MAIN_C_ORDER_H
